package core

// PktStatHeap target record heap
type PktStatHeap []*SpanRecord

func (h *PktStatHeap) Len() int           { return len(*h) }
func (h *PktStatHeap) Less(i, j int) bool { return (*h)[i].SpanID < (*h)[j].SpanID }
func (h *PktStatHeap) Swap(i, j int)      { (*h)[i], (*h)[j] = (*h)[j], (*h)[i] }

func (h *PktStatHeap) Push(b any) {
	*h = append(*h, b.(*SpanRecord))
}

func (h *PktStatHeap) Pop() any {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}
